import request from '@/utils/request'

// ==================== 学生端接口 ====================

/**
 * 查询我的变更申请列表
 */
export function listMyChangeRequests() {
  return request({
    url: '/system/topicChangeRequest/my/list',
    method: 'get'
  })
}

/**
 * 提交变更申请
 */
export function submitChangeRequest(data) {
  return request({
    url: '/system/topicChangeRequest/submit',
    method: 'post',
    data: data
  })
}

/**
 * 取消变更申请
 */
export function cancelChangeRequest(requestId) {
  return request({
    url: '/system/topicChangeRequest/cancel/' + requestId,
    method: 'put'
  })
}

/**
 * 检查是否可以提交申请
 */
export function checkCanSubmit() {
  return request({
    url: '/system/topicChangeRequest/check/canSubmit',
    method: 'get'
  })
}

/**
 * 查看我的申请详情
 */
export function getMyChangeRequestDetail(requestId) {
  return request({
    url: '/system/topicChangeRequest/my/detail/' + requestId,
    method: 'get'
  })
}

// ==================== 教师端接口 ====================

/**
 * 查询待审核的变更申请列表
 */
export function listPendingChangeRequests(query) {
  return request({
    url: '/system/topicChangeRequest/teacher/pendingList',
    method: 'get',
    params: query
  })
}

/**
 * 查询所有相关的变更申请列表
 */
export function listTeacherChangeRequests(query) {
  return request({
    url: '/system/topicChangeRequest/teacher/list',
    method: 'get',
    params: query
  })
}

/**
 * 查看申请详情（教师端）
 */
export function getTeacherChangeRequestDetail(requestId) {
  return request({
    url: '/system/topicChangeRequest/teacher/detail/' + requestId,
    method: 'get'
  })
}

/**
 * 原教师审核
 */
export function reviewAsOldTeacher(requestId, data) {
  return request({
    url: '/system/topicChangeRequest/teacher/reviewAsOld/' + requestId,
    method: 'put',
    data: data
  })
}

/**
 * 新教师审核
 */
export function reviewAsNewTeacher(requestId, data) {
  return request({
    url: '/system/topicChangeRequest/teacher/reviewAsNew/' + requestId,
    method: 'put',
    data: data
  })
}

/**
 * 导出变更申请列表
 */
export function exportChangeRequests() {
  return request({
    url: '/system/topicChangeRequest/teacher/export',
    method: 'post'
  })
}

// ==================== 管理员端接口 ====================

/**
 * 查询所有变更申请列表（管理员）
 */
export function listAllChangeRequests(query) {
  return request({
    url: '/system/topicChangeRequest/list',
    method: 'get',
    params: query
  })
}

/**
 * 获取变更申请详情（管理员）
 */
export function getChangeRequest(requestId) {
  return request({
    url: '/system/topicChangeRequest/' + requestId,
    method: 'get'
  })
}

/**
 * 删除变更申请
 */
export function delChangeRequest(requestIds) {
  return request({
    url: '/system/topicChangeRequest/' + requestIds,
    method: 'delete'
  })
}

/**
 * 导出变更申请列表（管理员）
 */
export function exportAllChangeRequests(query) {
  return request({
    url: '/system/topicChangeRequest/export',
    method: 'post',
    params: query
  })
}